Imports System.IO

Namespace OpenArchive
	Namespace IO
		Public Class ArchiveBinaryReader
			Inherits BinaryReader

			Public Sub New(ByVal input As Global.System.IO.Stream)
				MyBase.New(input, New Global.System.Text.ASCIIEncoding)
			End Sub
			Public Sub New(ByVal input As Global.System.IO.Stream, ByVal encoding As Global.System.Text.Encoding)
				MyBase.New(input, encoding)
			End Sub
			Public Overloads Function ReadBytes() As Byte()
				If MyBase.ReadBoolean Then
					Dim Longlenght As Long = MyBase.ReadInt64
					Return MyBase.ReadBytes(CInt(Longlenght))
				Else
					Return Nothing
				End If
			End Function
			Public Overloads Function ReadBytes(ByVal count As Integer) As Byte()
				If MyBase.ReadBoolean Then
					MyBase.ReadInt64()
					ReadBytes = MyBase.ReadBytes(count)
				Else
					Return Nothing
				End If
			End Function
			<Obsolete("Use ReadString", True)> _
   Public Overloads Function ReadChars() As Char()
				'If MyBase.ReadBoolean Then

				'Else
				'	Return Nothing
				'End If
            End Function
            Public Overloads Function ReadString() As String
                If ReadBoolean() Then Return MyBase.ReadString()
            End Function
			Public Overloads Function ReadVersion() As Version
                If MyBase.ReadBoolean Then
                    Dim major As Integer = ReadInt32()
                    Dim minor As Integer = ReadInt32()
                    Dim build As Integer = ReadInt32()
                    Dim revision As Integer = ReadInt32()
                    Return New Version(major, minor, build, revision)
                Else
                    Return Nothing
                End If
			End Function

		End Class
	End Namespace
End Namespace


